//
//  ROMainTabBarViewController.swift
//  健身宝
//
//  Created by hzt on 2017/9/26.
//  Copyright © 2017年 hzt. All rights reserved.
//

import UIKit

class ROMainTabBarViewController: RDVTabBarController {
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        setupTabBarController()
    }
    
    func setupTabBarController()
    {
        
        let TrainStoryboard : UIStoryboard = UIStoryboard(name: "Train", bundle: nil)
        let TrainNavigationController : UIViewController = TrainStoryboard.instantiateViewController(withIdentifier: "trainNav")
        
        let ClubStoryboard : UIStoryboard = UIStoryboard(name: "Club", bundle: nil)
        let ClubNavigationController : UIViewController = ClubStoryboard.instantiateViewController(withIdentifier: "clubNav")
        
        let HomeStoryboard : UIStoryboard = UIStoryboard(name: "Home", bundle: nil)
        let HomeNavigationController : UIViewController = HomeStoryboard.instantiateViewController(withIdentifier: "homeNav")
        
        let PhotoStoryBoard: UIStoryboard = UIStoryboard(name: "Photo", bundle: nil)
        let PhotoNavigationController: UIViewController = PhotoStoryBoard.instantiateViewController(withIdentifier: "photoNav")
        
        self.viewControllers = [TrainNavigationController,ClubNavigationController,HomeNavigationController,PhotoNavigationController]
        
        let tabBarItemImages = ["train","club","home","photo"]
        let tabBarItemTitles = ["培训","俱乐部","主页","晒图"]
        
        let tabBar = self.tabBar
        tabBar?.frame = CGRect(x: (tabBar?.frame.minX)!, y: (tabBar?.frame.minY)!, width: (tabBar?.frame.width)!, height: 63)
        var index : Int = 0
        
        for item  in self.tabBar.items as! [RDVTabBarItem]{
            
            let selectedimage = UIImage(named: "\(tabBarItemImages[index])"+"_select")
            let unselectedimage = UIImage(named: "\(tabBarItemImages[index])"+"_unselect")
            
            item.setFinishedSelectedImage(selectedimage, withFinishedUnselectedImage: unselectedimage)
            item.title = tabBarItemTitles[index]
            index += 1
        }
    }
    
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    
    
    /*
     // MARK: - Navigation
     
     // In a storyboard-based application, you will often want to do a little preparation before navigation
     override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
     // Get the new view controller using segue.destinationViewController.
     // Pass the selected object to the new view controller.
     }
     */
    
}

